/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.felinelayer.embedded;

import br.com.felinelayer.client.clientSwing.ClientSwing;
import br.com.felinelayer.server.Server;

/**
 *
 * @author Home
 */
public class Launcher {

    private static String serverHost;

    public static void main( String[] arg ) throws InterruptedException {
        boolean server = ( ( arg.length == 0 ) || ( arg[0].equalsIgnoreCase( "server" ) ) );
        boolean client = ( ( arg.length == 0 ) || ( arg[0].equalsIgnoreCase( "client" ) ) );
        serverHost = "localhost";
        if ( client && ( arg.length > 1 ) )
            serverHost = arg[1];
        // Start server
        if ( server ) {
            new Thread( new Runnable() {

                @Override
                public void run() {
                    Server.main( new String[]{} );
                }
            } ).start();
            Thread.sleep( 1000 );
        }
        // Start client
        if ( client )
            new Thread( new Runnable() {

                @Override
                public void run() {
                    ClientSwing.main( new String[]{ serverHost, "br.com.felinelayer.sample.Sample" } );
                }
            } ).start();
    }
}
